# -*- coding: utf-8 -*-
"""
@Time ： 2021/12/2 22:03
@Auth ： Mr. William 1052949192
@Company ：特斯汀学院 @testingedu.com.cn
@Function ：手q录制
"""
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
import time

from appium import webdriver

caps = {}
caps["platformName"] = "Android"
caps["deviceName"] = "127.0.0.1:7555"
caps["appPackage"] = "com.tencent.mobileqq"
caps["appActivity"] = ".activity.SplashActivity"
caps["noReset"] = "true"

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
driver.implicitly_wait(20)

# 启动app比较慢
time.sleep(8)

el1 = driver.find_element_by_accessibility_id("请输入QQ号码或手机或邮箱")
el1.send_keys("3599292078")
el2 = driver.find_element_by_accessibility_id("密码 安全")
el2.clear()
el2.send_keys("xiaobao168")
el3 = driver.find_element_by_accessibility_id("登 录")
el3.click()

# 登录跳转比较慢
time.sleep(5)

el4 = driver.find_element_by_accessibility_id("帐户及设置")
el4.click()
el5 = driver.find_element_by_accessibility_id("设置")
el5.click()
el6 = driver.find_element_by_id("com.tencent.mobileqq:id/account_switch")
el6.click()
el7 = driver.find_element_by_accessibility_id("退出当前帐号按钮")
el7.click()
els1 = driver.find_elements_by_xpath("//*[@text=\"退出登录\"]")
els1[0].click()
els2 = driver.find_elements_by_xpath("//*[@text=\"确定退出\"]")
els3 = driver.find_elements_by_xpath("//*[@text=\"确定退出\"]")
els3[0].click()

driver.quit()